home *** CD-ROM | disk | FTP | other *** search
- Path: in1.uu.net!interaccess!usenet
- From: brianmcg@interaccess.com (Brian V. McGroarty)
- Newsgroups: comp.lang.c
- Subject: Re: HELP. How to convert '0x12' into FF char?
- Date: 19 Mar 1996 02:10:18 GMT
- Organization: Internet Squire
- Message-ID: <4il52a$ma7@nntp.interaccess.com>
- References: <4iissm$s76@nntp.ucs.ubc.ca>
- Reply-To: brianmcg@interaccess.com
- NNTP-Posting-Host: d48-isdn.nhe.interaccess.com
- X-Newsreader: Internet Squire 1.20
-
- Gordon Wong wrote:
-
- >Let's say we have d='1' and e='2' and the following code segment:
- >:
- >:
- >f='0x';
- >strcpy(f,d);
- >strcpy(f,e);
- >
- >f now contains the string '0x12' right?
-
- No -- you need to use strcat to append sections -- assuming that d and e
- were strings, you would have placed "2" into f. I don't know of any
- character concatenation functions that are likely to come with your
- compiler, but one can be quickly written as something like:
-
- void CatChar( char *inString, char addChar )
- {
- inString[ strlen( inString ) + 1 ] = 0;
- inString[ strlen( inString ) ] = addChar;
- }
-
- ..make sure that inString is long enough to hold the extra character(s)
- though!
-
-
- >How would I write that out as a single ASCII FF character?
- >(d,e,f are char)
-
- I don't believe I understand the question. =^( If you are wondering how
- to fetch the value of this, look at sscanf(). If you are looking to
- concatenate these all at once, C doesn't have built in operators to append
- the characters to each other into a string.
-
-
- ---
- Brian Valters McGroarty -- brianmcg@bix.com
- phone/fax (847) 439-7714
-